/**     
* @Title: User.java   
* @Package me.security.example.entity   
* @Description: TODO   
* @author xaoyaoyao
* @date 2017年8月23日 下午4:06:10
*/
package me.security.example.entity;

import java.util.Collection;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * @ClassName: User
 * @Description: TODO
 * @author xaoyaoyao
 * @date 2017年8月23日 下午4:06:10
 * 
 */
public class User implements UserDetails {

	private static final long serialVersionUID = -8568117425147160012L;

	private Integer id;
	private String cnname;
	private String username;
	@JsonIgnore
	private String password;
	private String rePassword;
	private String historyPassword;
	private String email;
	@JsonIgnore
	private String telephone;
	private String mobilePhone;
	private List<? extends GrantedAuthority> authorities;
	private Role role;
	private Integer roleId;

	@JsonIgnore
	public boolean isAccountNonExpired() {
		return true;
	}

	@JsonIgnore
	public boolean isAccountNonLocked() {
		return true;
	}

	@JsonIgnore
	public boolean isCredentialsNonExpired() {
		return true;
	}

	@JsonIgnore
	public boolean isEnabled() {
		return true;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@JsonIgnore
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}

	public void setGrantedAuthorities(List<? extends GrantedAuthority> authorities) {
		this.authorities = authorities;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getCnname() {
		return cnname;
	}

	public void setCnname(String cnname) {
		this.cnname = cnname;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getMobilePhone() {
		return mobilePhone;
	}

	public void setMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
	}

	public String getRePassword() {
		return rePassword;
	}

	public void setRePassword(String rePassword) {
		this.rePassword = rePassword;
	}

	public String getHistoryPassword() {
		return historyPassword;
	}

	public void setHistoryPassword(String historyPassword) {
		this.historyPassword = historyPassword;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Integer getRoleId() {
		return roleId;
	}

	public void setRoleId(Integer roleId) {
		this.roleId = roleId;
	}

	@Override
	public String toString() {
		return "User{" + "id=" + id + ", cnname=" + cnname + ", username=" + username + ", password=" + password
				+ ", email=" + email + ", telephone=" + telephone + ", mobilePhone=" + mobilePhone + '}';
	}
}
